package com.jjb.www.utils;

import android.graphics.drawable.Drawable;

import androidx.annotation.ColorRes;
import androidx.annotation.DimenRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import androidx.core.content.ContextCompat;

import com.jjb.www.app.AppApplication;


/**
 * 资源
 */
public class ResUtils {

    public static String getString(@StringRes int resId) {
        String str = "";
        try {
            str = AppApplication.getApplication().getResources().getString(resId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return str;
    }

    public static int getColor(@ColorRes int resId) {
        return ContextCompat.getColor(AppApplication.getApplication(), resId);
    }

    public static float getDimen(@DimenRes int resId) {
        return AppApplication.getApplication().getResources().getDimension(resId);
    }

    public static Drawable getDrawable(@DrawableRes int resId) {
        return ContextCompat.getDrawable(AppApplication.getApplication(), resId);
    }
    
}
